package fr.cephb.berkeleydb.dom;

public class QName
	{
	private String prefix=null;
	private String localPart=null;
	private String namespaceURI=null;
	
	public QName(String prefix,String namespaceURI,String localPart)
		{
		this.namespaceURI=namespaceURI;
		this.prefix=prefix;
		this.localPart=localPart;
		}
	
	public String getLocalPart()
		{
		return localPart;
		}
	
	public String getPrefix()
		{
		return prefix;
		}
	
	public String getNamespaceURI()
		{
		return namespaceURI;
		}
	
	public String getNodeName()
		{
		if(this.prefix==null) return this.localPart;
		return this.prefix+":"+this.localPart;
		}
	

	@Override
	public int hashCode()
		{
		final int prime = 31;
		int result = 1;
		result = prime * result + localPart.hashCode();
		result = prime * result
				+ ((namespaceURI == null) ? 0 : namespaceURI.hashCode());
		return result;
		}

	@Override
	public boolean equals(Object obj)
		{
		if (this == obj) return true;
		if (obj == null) return false;
		if (getClass() != obj.getClass()) return false;
		QName other = (QName) obj;
		if (localPart == null)
			{
			if (other.localPart != null) return false;
			} else if (!localPart.equals(other.localPart)) return false;
		if (namespaceURI == null)
			{
			if (other.namespaceURI != null) return false;
			} else if (!namespaceURI.equals(other.namespaceURI)) return false;
		return true;
		}
	
	@Override
	public String toString()
		{
		return getNodeName();
		}
	
	}
